// 蜂窝蜜造平台生成代码，此文件只生成一次，不需要添加到 .beeignore

package com.fowo.api.service.impl;

import com.fowo.api.model.stock.out.StockOutCreateReceivableAction;
import com.fowo.api.model.stock.out.StockOutPushStockInAndStockOutAction;
import com.fowo.api.model.stock.out.StockOutPushStockOutAction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 原材料出库单 服务实现类
 */
@Service
public class StockOutRawMaterialServiceImpl
  extends StockOutRawMaterialBaseServiceImpl {

    @Autowired(required = false)
    protected StockOutPushStockOutAction stockOutPushStockOutAction;

    @Autowired(required = false)
    protected StockOutPushStockInAndStockOutAction stockOutPushStockInAndStockOutAction;

    @Autowired(required = false)
    protected StockOutCreateReceivableAction stockOutCreateReceivableAction;

    /**
     * 下推其他入库单
     */
    @Override
    public void pushStockOut(Long id) throws Exception {
        if (stockOutPushStockOutAction == null) {
            throw new Exception("此操作当前不可用");
        }
        stockOutPushStockOutAction.run(id);
    }

    /**
     * 下推生成入库单和出库单(工厂)
     */
    @Override
    public void pushStockInAndStockOut(Long id) throws Exception {
        if (stockOutPushStockInAndStockOutAction == null) {
            throw new Exception("此操作当前不可用");
        }
        stockOutPushStockInAndStockOutAction.run(id);
    }

    /**
     * 生成应收单
     */
    @Override
    public void createReceivable(Long id) throws Exception {
        if (stockOutCreateReceivableAction == null) {
            throw new Exception("此操作当前不可用");
        }
        stockOutCreateReceivableAction.run(id);
    }
}
